import type { FormRules } from 'element-plus'
import { reactive } from 'vue'
export const form = reactive({
  businesstype: '',
  companyname: '',
  sitename: '',
  sitecode: '',
  area: '',
  address: '',
  longitude: '',
  latitude: '',
  userproperty: '',
  usertype: '',
  electrictip: [
    []
  ],
  electricpeak: [
    []
  ],
  electricflat: [
    []
  ],
  electriclower: [
    []
  ]
})

export const rules = reactive<FormRules>({
  businesstype: [{ required: true, message: '请选择业务类型' }],
  companyname: [{ required: true, message: '请输入企业名称' }],
  sitename: [{ required: true, message: '请输入站点名称' }],
  sitecode: [{ required: true, message: '请输入站点编号' }],
  area: [{ required: true, message: '请选择区域地址所在地' }],
  address: [{ required: true, message: '请输入详细地址' }],
  longitude: [{ required: true, message: '请输入站点经度' }],
  latitude: [{ required: true, message: '请输入站点纬度' }],
  userproperty: [{ required: true, message: '请选择用户性质' }],
  usertype: [{ required: true, message: '请选择用户类别' }],
})
export const saveAdd = (callback?: Function) => {
  typeof callback === 'function' && callback()
}
export const queryEdit = (id: string) => {
  console.log('id:==', id)
} 
export const saveEdit = (callback?: Function) => {
  typeof callback === 'function' && callback()
}
export const saveDel = (id: string, callback?: Function) => {
  console.log('id--:', id)
  typeof callback === 'function' && callback()
}

export const eleTipDel = (index: number) => {
  form.electrictip.splice(index, 1)
}
export const eleTipAdd = () => {
  form.electrictip.push([])
}

export const elePeakDel = (index: number) => {
  form.electricpeak.splice(index, 1)
}
export const elePeakAdd = () => {
  form.electricpeak.push([])
}

export const eleFlatDel = (index: number) => {
  form.electricflat.splice(index, 1)
}
export const eleFlatAdd = () => {
  form.electricflat.push([])
}

export const eleLowerDel = (index: number) => {
  form.electriclower.splice(index, 1)
}
export const eleLowerAdd = () => {
  form.electriclower.push([])
}